#include "stdafx.h"
#include "CSymbol.h"


//base symbools

CSymbol::CSymbol(void)
{
}

CSymbol::CSymbol(CPoint pBegin, CPoint pEnd)
{
}
BOOL CSymbol::Draw(CDC *cDC)
{
	return FALSE;
}


CSymbol::~CSymbol(void)
{

}

// class plus
CPlus::CPlus(CPoint point)
{
	this->m_pBegin	= point;
	this->m_pEnd	= point;
	m_nAngle = 4;
	m_pCoordinates = new CPoint[m_nAngle];
	m_cPenColor = RGB(0, 0, 0);
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

CPlus::CPlus (CPoint m_pBegin, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType)
{
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pBegin;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
	m_nAngle = NUM_OF_ANGLE;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

void CPlus::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}

BOOL CPlus::Draw(CDC *cDC)
{
	int lpPts[] = { 2, 2 };
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->PolyPolygon(m_pCoordinates, lpPts, 2);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return FALSE;
}

void CPlus::setCoordinate()
{

	this->m_pCoordinates[0].x = this->m_pBegin.x;
	this->m_pCoordinates[0].y = this->m_pBegin.y - 3;
	this->m_pCoordinates[1].x = this->m_pBegin.x;
	this->m_pCoordinates[1].y = this->m_pBegin.y + 3;

	this->m_pCoordinates[2].x = this->m_pBegin.x - 3;
	this->m_pCoordinates[2].y = this->m_pBegin.y;
	this->m_pCoordinates[3].x = this->m_pBegin.x + 3;
	this->m_pCoordinates[3].y = this->m_pBegin.y;
}

CPlusCircle::CPlusCircle(CPoint point)
{
	this->m_pBegin = point;
	this->m_pEnd = point;
	m_nAngle = 4;
	m_pCoordinates = new CPoint[4];
	m_cPenColor = RGB(0, 0, 0);
	m_nPenStyle = PS_SOLID;
	m_brushColor.CreateSolidBrush(RGB(255, 255, 255));
	m_nPenWidth = 1;
}

CPlusCircle::CPlusCircle (CPoint m_pBegin, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType)
{
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pBegin;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
	m_nAngle = 4;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

void CPlusCircle::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}

BOOL CPlusCircle::Draw(CDC *cDC)
{
	int lpPts[] = { 2, 2 };
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->Ellipse(m_rectEclipse);
	cDC->PolyPolygon(m_pCoordinates, lpPts, 2);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return FALSE;
}

void CPlusCircle::setCoordinate()
{
	CPoint m_pT(10, 10);
	CRect m_rectT(m_pBegin, m_pEnd);
	this->m_pEnd = this->m_pBegin + m_pT;
	m_rectEclipse.TopLeft() = this->m_pBegin;
	m_rectEclipse.BottomRight() = this->m_pEnd;
	
	this->m_pCoordinates[0].x = (this->m_pBegin.x + this->m_pEnd.x) / 2;
	this->m_pCoordinates[0].y = (this->m_pBegin.y + this->m_pEnd.y) / 2 - 2;
	this->m_pCoordinates[1].x = (this->m_pBegin.x + this->m_pEnd.x) / 2;
	this->m_pCoordinates[1].y = (this->m_pBegin.y + this->m_pEnd.y) / 2 + 2;

	this->m_pCoordinates[2].x = (this->m_pBegin.x + this->m_pEnd.x) / 2 - 2;
	this->m_pCoordinates[2].y = (this->m_pBegin.y + this->m_pEnd.y) / 2;
	this->m_pCoordinates[3].x = (this->m_pBegin.x + this->m_pEnd.x) / 2 + 2;
	this->m_pCoordinates[3].y = (this->m_pBegin.y + this->m_pEnd.y) / 2;
}

//class sub

CSub::CSub(CPoint point)
{
	this->m_pBegin	= point;
	this->m_pEnd	= point;
	m_nAngle = 2;
	m_pCoordinates = new CPoint[m_nAngle];
	m_cPenColor = RGB(0, 0, 0);
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

CSub::CSub (CPoint m_pBegin, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType)
{
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pBegin;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
	m_nAngle = 2;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

void CSub::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}

BOOL CSub::Draw(CDC *cDC)
{
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->Polygon(m_pCoordinates, 2);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return FALSE;
}

void CSub::setCoordinate()
{
	this->m_pCoordinates[0].x = this->m_pBegin.x - 3;
	this->m_pCoordinates[0].y = this->m_pBegin.y;
	this->m_pCoordinates[1].x = this->m_pBegin.x + 2;
	this->m_pCoordinates[1].y = this->m_pBegin.y;
}

//class subcircle

CSubCircle::CSubCircle(CPoint point)
{
	this->m_pBegin	= point;
	m_nAngle = 2;
	m_pCoordinates = new CPoint[m_nAngle];
	m_cPenColor = RGB(0, 0, 0);
	m_nPenStyle = PS_SOLID;
	m_brushColor.CreateSolidBrush(RGB(255, 255, 255));
	m_nPenWidth = 1;
}

CSubCircle::CSubCircle (CPoint m_pBegin, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType)
{
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pBegin;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
	m_nAngle = 2;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

void CSubCircle::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}

BOOL CSubCircle::Draw(CDC *cDC)
{
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->Ellipse(m_rectEclipse);
	cDC->Polygon(m_pCoordinates, 2);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return FALSE;
}

void CSubCircle::setCoordinate()
{
	CPoint m_pT(10, 10);
	CRect m_rectT(m_pBegin, m_pEnd);
	this->m_pEnd = this->m_pBegin + m_pT;
	m_rectEclipse.TopLeft() = this->m_pBegin;
	m_rectEclipse.BottomRight() = this->m_pEnd;

	this->m_pCoordinates[0].x = (this->m_pBegin.x + this->m_pEnd.x) / 2 - 3;
	this->m_pCoordinates[0].y = (this->m_pBegin.y + this->m_pEnd.y) / 2;
	this->m_pCoordinates[1].x = (this->m_pBegin.x + this->m_pEnd.x) / 2 + 2;
	this->m_pCoordinates[1].y = (this->m_pBegin.y + this->m_pEnd.y) / 2;
	
}

//class subpoint

CSubPoint::CSubPoint(CPoint point)
{
	this->m_pBegin	= point;
	m_nAngle = 2;
	m_pCoordinates = new CPoint[2];
	m_cPenColor = RGB(0, 0, 0);
	m_nPenStyle = PS_SOLID;
	m_brushColor.CreateSolidBrush(RGB(0, 0, 0));
	m_nPenWidth = 1;
}

CSubPoint::CSubPoint (CPoint m_pBegin, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType)
{
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pBegin;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
	m_nAngle = 2;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

void CSubPoint::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}

BOOL CSubPoint::Draw(CDC *cDC)
{
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->Ellipse(m_rectEclipse);
	cDC->Polygon(m_pCoordinates, 2);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return FALSE;
}

void CSubPoint::setCoordinate()
{
	CPoint m_pT(4, 4);
	CRect m_rectT(m_pBegin, m_pEnd);
	this->m_pEnd = this->m_pBegin + m_pT;
	m_rectEclipse.TopLeft() = this->m_pBegin;
	m_rectEclipse.BottomRight() = this->m_pEnd;

	this->m_pCoordinates[0].x = ((this->m_pBegin.x + this->m_pEnd.x) / 2 - 5) ;
	this->m_pCoordinates[0].y = ((this->m_pBegin.y + this->m_pEnd.y) / 2) -5;
	this->m_pCoordinates[1].x = (this->m_pBegin.x + this->m_pEnd.x) / 2 + 4;
	this->m_pCoordinates[1].y = ((this->m_pBegin.y + this->m_pEnd.y) / 2) -5;
}

//class OnePoint

COnePoint::COnePoint(CPoint point)
{
	this->m_pBegin	= point;
	m_nAngle = NUM_OF_ANGLE;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_cPenColor = RGB(0, 0, 0);
	m_nPenStyle = PS_SOLID;
	m_brushColor.CreateSolidBrush(RGB(0, 0, 0));
	m_nPenWidth = 1;
}

COnePoint::COnePoint (CPoint m_pBegin, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType)
{
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pBegin;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
//	m_nAngle = 2;
//	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

void COnePoint::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}

BOOL COnePoint::Draw(CDC *cDC)
{
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->Ellipse(m_rectEclipse);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return FALSE;
}

void COnePoint::setCoordinate()
{
	CPoint m_pT(4, 4);
	CRect m_rectT(m_pBegin, m_pEnd);
	this->m_pEnd = this->m_pBegin + m_pT;
	m_rectEclipse.TopLeft() = this->m_pBegin;
	m_rectEclipse.BottomRight() = this->m_pEnd;
}

//class DoublePoint


CDoublePoint::CDoublePoint(CPoint point)
{
	this->m_pBegin	= point;
	m_nAngle = 4;
	m_pCoordinates = new CPoint[m_nAngle];
	m_cPenColor = RGB(0, 0, 0);
	m_brushColor.CreateSolidBrush(RGB(0, 0, 0));
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 3;
}

CDoublePoint::CDoublePoint (CPoint m_pBegin, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType)
{
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pBegin;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
	m_nAngle = 4;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 3;
}

void CDoublePoint::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}

BOOL CDoublePoint::Draw(CDC *cDC)
{
	int lpts[] = { 2, 2 };
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->PolyPolygon(m_pCoordinates, lpts, 2);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return FALSE;
}

void CDoublePoint::setCoordinate()
{
	m_pCoordinates[0] = m_pBegin;
	m_pCoordinates[1] = CPoint(m_pBegin.x + 1, m_pBegin.y + 1);
	m_pCoordinates[2] = CPoint(m_pBegin.x, m_pBegin.y + 7);
	m_pCoordinates[3] = CPoint(m_pBegin.x + 1, m_pBegin.y + 8);
}

//plus point

CPlusPoint::CPlusPoint(CPoint point)
{
	this->m_pBegin	= point;
	m_nAngle = 4;
	m_pCoordinates = new CPoint[m_nAngle];
	m_cPenColor = RGB(0, 0, 0);
	m_nPenStyle = PS_SOLID;
	m_brushColor.CreateSolidBrush(RGB(0, 0, 0));
	m_nPenWidth = 1;
}

void CPlusPoint::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}

CPlusPoint::CPlusPoint (CPoint m_pBegin, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType)
{
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pBegin;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
	m_nAngle = 4;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

BOOL CPlusPoint::Draw(CDC *cDC)
{
	int lpts[] = {2, 2};
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->Ellipse(m_rectEclipse);
	cDC->PolyPolygon(m_pCoordinates, lpts, 2);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return FALSE;
}

void CPlusPoint::setCoordinate()
{
	CPoint m_pT(4, 4);
	CRect m_rectT(m_pBegin, m_pEnd);
	this->m_pEnd = this->m_pBegin + m_pT;
	m_rectEclipse.TopLeft() = this->m_pBegin;
	m_rectEclipse.BottomRight() = this->m_pEnd;

	this->m_pCoordinates[0].x = (this->m_pBegin.x + this->m_pEnd.x) / 2 -1;
	this->m_pCoordinates[0].y = (this->m_pBegin.y + this->m_pEnd.y) / 2 -12;
	this->m_pCoordinates[1].x = (this->m_pBegin.x + this->m_pEnd.x) / 2 -1;
	this->m_pCoordinates[1].y = (this->m_pBegin.y + this->m_pEnd.y) / 2 - 5;

	this->m_pCoordinates[2].x = ((this->m_pBegin.x + this->m_pEnd.x) / 2 - 5) ;
	this->m_pCoordinates[2].y = ((this->m_pBegin.y + this->m_pEnd.y) / 2) -8;
	this->m_pCoordinates[3].x = (this->m_pBegin.x + this->m_pEnd.x) / 2 + 4;
	this->m_pCoordinates[3].y = ((this->m_pBegin.y + this->m_pEnd.y) / 2) -8;
}

/******************************Cap nhat ham huy cho cac Symbol class **************************************/
CSubPoint::~CSubPoint()
{
}

CSubCircle::~CSubCircle()
{
}

CSub::~CSub()
{
}

CPlusPoint::~CPlusPoint()
{
}

CPlusCircle::~CPlusCircle()
{
}

CPlus::~CPlus()
{
}

COnePoint::~COnePoint()
{
}

CDoublePoint::~CDoublePoint()
{
}
/************************************ Ket thuc phan cap nhat ham huy ********************************/